<script lang="ts" setup>
//带背景图的标题
import Share from "./Share.vue";
import { ElTooltip } from "element-plus";

import { ref, computed } from "vue";
import { IndexShowData } from "@/api/interface";
export interface Props {
  data: IndexShowData;
}

//接收数据
const props = defineProps<Props>();

//不超过26个字，则使用居中
const active = computed(() => {
  if (props.data && props.data.title) {
    return props.data.title.length > 27 ? "article-header" : "featured-header";
  } else {
    return "";
  }
});
</script>

<template>
  <div class="card" v-if="data">
    <!--遮罩-->
    <div class="scrollfade"></div>
    <!--背景图-->
    <div
      class="curtain"
      :style="{ backgroundImage: 'url(' + data.image.url + ')' }"
    ></div>
    <!--内容-->
    <div class="content">
      <div :class="active">
        <!--分类和时间-->
        <div class="category component">
          <div class="component-content">
            <div class="category-eyebrow">
              <span class="category-eyebrow__category">
                <el-tooltip
                  class="box-item"
                  effect="dark"
                  content="查看分类信息"
                  placement="right"
                >
                  <span>
                    <router-link
                      :to="`/category/${item.id}`"
                      :key="item.id"
                      v-for="item in data.cat"
                    >
                      {{ item.name }}
                    </router-link>
                  </span>
                </el-tooltip>
              </span>

              <span class="category-eyebrow__date"> {{ data.date }}</span>
            </div>
          </div>
        </div>
        <!--标题-->
        <div class="pagetitle component">
          <div class="component-content">
            <h1 class="hero-headline">
              {{ data.title }}
            </h1>
          </div>
        </div>
        <!--副标题-->
        <div class="article-subhead component">
          <div class="component-content">
            <div v-html="data.excerpt"></div>
          </div>
        </div>
        <!--社交分享-->
        <div class="sharesheet component">
          <div class="component-content">
            <Share :postData="data"></Share>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div v-else>
    <el-skeleton animated :throttle="500">
      <template #template>
        <div class="card">
          <!--遮罩-->
          <div class="scrollfade"></div>
          <!--内容-->
          <div class="content">
            <div :class="active">
              <!--分类和时间-->
              <div class="category component">
                <div class="component-content">
                  <div class="category-eyebrow">
                    <span class="category-eyebrow__category">
                      <span>
                        <el-skeleton-item variant="text" style="width: 15%" />
                        &nbsp;·&nbsp;
                        <el-skeleton-item variant="text" style="width: 35%" />
                      </span>
                    </span>
                  </div>
                </div>
              </div>
              <!--标题-->
              <div class="pagetitle component">
                <div class="component-content">
                  <h1 class="hero-headline">
                    <el-skeleton-item variant="h1" style="width: 200px" />
                  </h1>
                </div>
              </div>
              <!--副标题-->
              <div class="article-subhead component">
                <div class="component-content">
                  <el-skeleton-item variant="h3" style="width: 50%" />
                </div>
              </div>
              <!--社交分享-->
              <div class="sharesheet component">
                <div class="component-content">
                  <el-skeleton-item variant="h3" style="width: 35%" />
                </div>
              </div>
            </div>
          </div>
        </div>
      </template>
    </el-skeleton>
  </div>
</template>

<style lang="less" scoped>
//全屏研究
.card {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 90vh;
  .scrollfade {
    background-color: black;
    display: block;
    height: 100%;
    left: 0;
    opacity: 0.7;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 1;
  }
  .curtain {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    background-attachment: fixed;
    -ms-background-size: cover;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
  }
  .content {
    position: relative;
    z-index: 2;
  }
}
.category.component {
  margin-top: 0;
  margin-bottom: 20px;
}

.category-eyebrow {
  font-size: 12px;
  line-height: 1.33337;
  font-weight: 700;
  letter-spacing: 0em;
  font-family: "SF Pro Text", "SF Pro Icons", "Helvetica Neue", "Helvetica",
    "Arial", sans-serif;
}

.category-eyebrow__category {
  text-transform: uppercase;
  color: #6e6e73;
  border-color: #6e6e73;
  a {
    margin-right: 10px;
    color: inherit;
    font-weight: inherit;
  }
}
.category-eyebrow__category,
.category-eyebrow__date {
  display: block;
}

.category-eyebrow__date {
  font-size: 14px;
  line-height: 1.28577;
  font-weight: 600;

  font-family: @font-family-main;
  letter-spacing: 0em;
  margin-top: 4px;
  color: @font-color-assist;
}

//标题
.pagetitle.component {
  margin-top: 0;
  margin-bottom: 0;
}
.hero-headline {
  font-size: 48px;
  line-height: 1.08349;
  font-weight: 700;
  //letter-spacing: -.003em;
  letter-spacing: 0em;
  font-family: "SF Pro SC", "SF Pro Display", "SF Pro Icons", "PingFang SC",
    "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
//副标题
.article-subhead {
  font-size: 24px;
  line-height: 1.16667;
  font-weight: 500;
  letter-spacing: 0.009em;
  font-family: "SF Pro SC", sans-serif;
  margin-top: 20px;
  margin-bottom: 0;
}

.sharesheet {
  margin-bottom: 0;
  margin-top: 24px;
}

//-------------------------------------------//
//居中样式
.featured-header {
  .category-eyebrow {
    display: flex;
    justify-content: center;
    margin-top: 16px;
  }
  .category-eyebrow__category,
  .category-eyebrow__date {
    color: #6e6e73;
    margin: 4px 0;
  }
  .category-eyebrow__category {
    display: flex;
    align-items: center;
  }
  .category-eyebrow__category::after {
    color: #6e6e73;
    content: "\2022";
    margin: 0 8px;
  }
  .pagetitle {
    .component-content {
      width: 83.33333%;
    }
  }

  .article-subhead {
    text-align: center;
  }
  .sharesheet {
    text-align: center;
    margin-top: 24px;
    margin-bottom: 0;
  }
}

//标题
.hero-headline {
  font-size: 56px;
  line-height: 1.07143;
  font-weight: 700;
  letter-spacing: 0em;
  font-family: "SF Pro SC", "SF Pro Display", "SF Pro Icons", "PingFang SC",
    "Helvetica Neue", "Helvetica", "Arial", sans-serif;
  text-align: center;
}
@media only screen and (max-width: 1068px) {
  .pagetitle {
    .hero-headline {
      font-size: 40px;
      line-height: 1.1;
      font-weight: 700;
    }
  }

  .article-subhead {
    font-size: 21px;
    line-height: 1.19048;
    font-weight: 500;
    letter-spacing: 0.011em;
  }
}
@media only screen and (max-width: 734px) {
  .category-eyebrow {
    margin-top: 20px;
  }
  .pagetitle {
    .component-content {
      margin-left: auto;
      margin-right: auto;
      width: 87.5%;
    }
    .hero-headline {
      font-size: 32px;
      line-height: 1.125;
      font-weight: 700;
    }
  }
  .sharesheet {
    margin-top: 20px;
  }
}

.content {
  a,
  span,
  h1,
  .article-subhead,
  .sharesheet :deep(i) {
    color: #f5f5f7 !important;
  }
}
</style>
